package cn.tedu;

import cn.tedu.handler.MyIncationHandler;
import cn.tedu.service.SomeService;
import cn.tedu.service.impl.SomeServiceImpl;

import java.lang.reflect.Proxy;

public class MyApp {
    public static void main(String[] args) {
        SomeServiceImpl target = new SomeServiceImpl();
        MyIncationHandler handler = new MyIncationHandler(target);
        //Proxy.newProxyInstance(业务类的类加载器, 反射业务类实现的接口, 自定义的代理类对象);
        SomeService proxy = (SomeService) Proxy.newProxyInstance(target.getClass().getClassLoader(),
                                 target.getClass().getInterfaces(), handler);
        proxy.doSome();
        System.out.println("========");
        proxy.doOther();
    }
}
